/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package TreeView;

/**
 *
 * @author Mr.Sam
 */
import java.awt.*;

public class TreeTick extends Canvas {
    private float hGap;
    private float vGap;
    private int tickType; 
    
    public TreeTick() {
        this(0.75f, 0.5f, MIDDLE);
    }
    
    public TreeTick(float hGap, float vGap, int tickType) {
        this.hGap = hGap;
        this.vGap = vGap;
        this.tickType = tickType;
    }
    
    public void setHGap(float hGap) {
        this.hGap = hGap;
    }
    
    public float getHGap() {
        return hGap;
    }
    
    public void setVGap(float vGap) {
        this.vGap = vGap;
    }
    
    public float getvGap() {
        return vGap;
    }
    
    public void setTickType(int tickType) {
        this.tickType = tickType;
    }
    
    public int getTickType() {
        return tickType;
    }
    
    public Dimension getPreferredSize() {
        return new Dimension(50, 10);
    }
    
    public void paint(Graphics g) {
        Dimension size = getSize();
        
        int _hGap = (int) Math.round(hGap*size.width);
        int _vGap = (int) Math.round(vGap*size.height);
        
        // Dessin du trait horizontal
        g.drawLine(_hGap, _vGap, size.width, _vGap);
        
        // Dessin du trait vertical
        switch(tickType) {
            case TOP :
                g.drawLine(_hGap, _vGap, _hGap, size.height);
                break;
            case MIDDLE :
                g.drawLine(_hGap, 0, _hGap, size.height);
                break;
            case BOTTOM :
                g.drawLine(_hGap, 0, _hGap, _vGap);
                break;
            case NONE :
                break;
            default :
                g.drawLine(_hGap, 0, _hGap, size.height);
        }
    }
    
    public static final int TOP     = 0;
    public static final int MIDDLE  = 1;
    public static final int BOTTOM  = 2;
    public static final int NONE    = 3;
}
